/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FrmConsultaCep.java
 *
 * Created on 28/10/2009, 09:53:08
 */

package endereco.telas;

import conexao.DAOException;
import endereco.classes.Endereco;
import endereco.classes.EnderecoTableModel;
import endereco.db.EnderecoDao;
import java.awt.Image;
import java.awt.Toolkit;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import javax.swing.UIManager;

/**
 *
 * @author Acer
 */
public class FrmConsultaEndereco extends javax.swing.JFrame {

    private EnderecoDao dao = null;
    private EnderecoTableModel model = null;

    /** Creates new form FrmConsultaCep */
    public FrmConsultaEndereco(String logradouro) {
        try {
            dao = new EnderecoDao();
            List<Endereco> listaEnderecos = dao.consultarEndereco(logradouro);
            model = new EnderecoTableModel(listaEnderecos);
           } catch (DAOException ex) {
            ex.printStackTrace();
            model = new EnderecoTableModel(new ArrayList<Endereco>());
           }
        initComponents();
        URL url = this.getClass().getResource("/imagens/logo_mini.png");
        Image imagemTitulo = Toolkit.getDefaultToolkit().getImage(url);
        this.setIconImage(imagemTitulo);
        try{
            UIManager.setLookAndFeel("com.birosoft.liquid.LiquidLookAndFeel");
        }catch (Exception e){
            e.printStackTrace();
        }
        enderecojTable.setModel(model);
        enderecojTable.getColumnModel().getColumn(0).setPreferredWidth(10);
        enderecojTable.getColumnModel().getColumn(1).setPreferredWidth(200);
        enderecojTable.getColumnModel().getColumn(2).setPreferredWidth(10);
        enderecojTable.getColumnModel().getColumn(3).setPreferredWidth(100);
        enderecojTable.getColumnModel().getColumn(4).setPreferredWidth(100);
        enderecojTable.getColumnModel().getColumn(5).setPreferredWidth(10);
        setVisible(true);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        enderecojTable = new javax.swing.JTable();
        jPanel5 = new javax.swing.JPanel();
        confirmajButton = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Consulta de Endereços");
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
        getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, -1, -1));

        jPanel2.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
        getContentPane().add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 30, -1, -1));

        jPanel3.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
        getContentPane().add(jPanel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 150, 320, -1));

        jPanel4.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        enderecojTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(enderecojTable);

        jPanel4.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 10, 600, 130));

        jPanel5.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel5.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        confirmajButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/tick.png"))); // NOI18N
        confirmajButton.setText("Confirma");
        confirmajButton.setToolTipText("Salvar Lançamento");
        jPanel5.add(confirmajButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 8, -1, -1));

        jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/cross.png"))); // NOI18N
        jButton4.setText("Fechar");
        jButton4.setToolTipText("Fechar");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4fecharMovimentoCaixa(evt);
            }
        });
        jPanel5.add(jButton4, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 8, 100, -1));

        jPanel4.add(jPanel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 150, 380, 40));

        getContentPane().add(jPanel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 610, 200));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton4fecharMovimentoCaixa(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4fecharMovimentoCaixa
        // TODO add your handling code here:
        this.dispose();
}//GEN-LAST:event_jButton4fecharMovimentoCaixa

    /**
    * @param args the command line arguments
    */
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton confirmajButton;
    private javax.swing.JTable enderecojTable;
    private javax.swing.JButton jButton4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables

}
